<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>China FullFill</title>
<script type="text/javascript" src="/js/jquery.min.js"></script>
<link href="/css/main-css3.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="/js/main.js"></script>
<script type="text/javascript" src="/js/jquery-ui.js"></script>
<link href="/css/blitzer/jquery-ui.css" rel="stylesheet" type="text/css">
<script>
	var jsonData = <{$jsonFileDatas}>;
	$(function(){
		$("#checkResultDialog").dialog({
			autoOpen:false,
			modal:true,
			width:500
		});
		
		$("#tipDialog").dialog({
			autoOpen:false,
			modal:true,
			show:"slide",
			buttons:{
				"OK":function(){
					$(this).dialog("close");
					$.ajax({
							url:"/merchant/product/upload-save",
							dataType:"json",
							type:"post",
							data:{"data":jsonData},
							success:function(json){
								location.href="/merchant/product/list"
							}
						});
				},
				"Cancel":function(){
					$(this).dialog("close");
				}
			}
		});
	
		$("td").dblclick(function(){
			var html = '<input type="text" name="'+$(this).attr("name")+'" value="'+$(this).html()+'" class="onModify"  title="'+$(this).attr("title")+'">';
			$(this).html(html);
			$(".onModify").dblclick(function(){
				return false;
			});
			$(".onModify").focus();
			var value = $(".onModify").val();
			$(".onModify").val("");
			$(".onModify").val(value);
			$(".onModify").blur(function(){
				$(this).parent().html($(this).val());
				//修改jsonData数据
				if(typeof jsonData[$(this).attr("title")][$(this).attr("name")] != "undefined"){
					jsonData[$(this).attr("title")][$(this).attr("name")] = $(this).val();
				}
			});
		});
		$("[name=checkData]").click(function(){
			var strData =jsonData;
			$.ajax({
				url:"/merchant/product/check-upload-data",
				dataType:"json",
				type:"post",
				data:{"data":strData},
				success:function(json){
					var showID = "";
					var html = '<table class="result-tab" width="100%">';
					html += '<tr><th class="title">产品序号</td><th class="title">错误消息</td></tr>';
					$.each(json,function(k,v){
						
						if(v != ""){
							html += "<tr><td align='center'>"+k+"</td><td>"+v+"</td></tr>";
							$("#product"+k).html("<th colspan='8'>"+v+"</th>");
							showID += "#product"+k+",";
						}
						
					});
					html += '</table>';
					if(showID != ""){
						html += '<input type="button" name="showError" value="在列表中显示错误"/>';
					}
					html += '<input type="button" value="提交" name="submit"/><input type="button" value="返回继续修改" name="cancel"/>';
						$("#checkResultDialog").html(html);
						$("[name=showError]").click(function(){
							$(showID).show();
							$("#checkResultDialog").dialog("close");
						});
						$("[name=cancel]").click(function(){
							$("#checkResultDialog").dialog("close");
						});
						$("[name=submit]").click(function(){
							$("#tipDialog").dialog("open");
							
						});
						$("#checkResultDialog").dialog("open");
				}
			});
		});
	});

</script>
<style>
	html{background:#F2F8FD}
	.bgc{background:#F2F8FD}
	.radiu{-webkit-border-radius: 10px;-moz-border-radius:10px;border-radius:10px;overflow: hidden;}
	.info-top{height:10px}
	.tab-li{ float:left; padding:0; cursor:pointer; background:url(/images/menu-li-bg.gif) no-repeat center top; width:92px; height:25px; line-height:25px; text-align:center; color:white}
	.tab-li-click{background:url(/images/menu-li-bg-hover.gif) no-repeat center top}
	.tab-li:hover{ background:url(/images/menu-li-bg-hover.gif) no-repeat center top}
	.info-header{width:100%;min-height:500px;background:url(/images/nav-bg.png) no-repeat center top;border-bottom:1px solid #CCC;position:relative}
	.info-header h3{text-indent:10px;}
	.info-content{}
	.info-content-body{border-top:1px solid #CCC;width:100%;clear:both;min-height: 200px;}
	.info-content-menu{border-top:1px solid #CCC;width:100%;height:25px}
	.info-header-content{position:absolute;top:50px;width:900px;border:1px solid #CCC;}
	.cell20{width:180px;height:25px;line-height:25px;display:inline-block;overflow:hidden;border-bottom:1px solid #CCC;margin:0px;border-right:1px solid #CCC;margin:0px;float:left}
	.cell30{width:253px;height:25px;line-height:25px;display:inline-block;overflow:hidden;border-bottom:1px solid #CCC;margin:0px;border-right:1px solid #CCC;margin:0px;margin:0px;float:left}
	.no-bottom{border-bottom:none}
	.no-right{border-right:none}
	
	.edit-tab{margin-top:10px}
	.bwhite{background:white}
	tr{border:1px solid cornflowerblue;}
	td{border:1px solid cornflowerblue;border-bottom:none;border-top:none;}
	th{border:1px solid cornflowerblue;border-bottom:none;border-top:none;}
	.title{background:navajowhite;text-align:center}
	.row-title{background:navajowhite;text-align:center}
	.edit-tab-width10:{width:10%}
	.edit-tab-width15:{width:15%}
	
	.error{color:red;text-align:center;border:1px solid red}
</style>
</head>
<body class="bgc">
<div class="info-top">
</div>
<div class="main radiu">
<div class="main-body radiu">
<div class="content bgc">
	<div class="info-header radiu">
		<h3 class="radiu">产品上传文件编辑</h3>
		<form>
			<table width="100%" cellspacing="0" border=0 class="edit-tab">
			<{foreach from=$fileDatas item=fileData key=key}>
				<tr class="<{if $key%2 != 0}>bwhite<{/if}>">
					<th rowspan="5" class="center"><{$key}></td>
					<th class="title">产品名称</td>
					<th class="title">产品编号</td>
					<th class="title">申报价值</td>
					<th class="title">重量</td>
					<th class="title">长</td>
					<th class="title">宽</td>
					<th class="title">高</td>
				</tr>
				<tr class="<{if $key%2 != 0}>bwhite<{/if}>">
					<td class="center" title="<{$key}>" name="product_title"><{$fileData.SKUName}></td>
					<td class="center" title="<{$key}>" name="product_sku"><{$fileData.SKUNo}></td>
					<td class="center" title="<{$key}>" name="Declare Value"><{$fileData.product_declared_value}></td>
					<td class="center" title="<{$key}>" name="product_weight"><{$fileData.product_weight}></td>
					<td class="center" title="<{$key}>" name="product_length"><{$fileData.product_length}></td>
					<td class="center" title="<{$key}>" name="product_height"><{$fileData.product_height}></td>
					<td class="center" title="<{$key}>" name="product_width"><{$fileData.product_width}></td>
				</tr>
				<tr class="<{if $key%2 != 0}>bwhite<{/if}>"> 
					<th class="row-title">产品类别</td>
					<td colspan="6" title="<{$key}>" name="Category"><{$fileData.Category}></td>
				</tr>
				<tr class="<{if $key%2 != 0}>bwhite<{/if}>"> 
					<th class="row-title">UOM</td>
					<td colspan="6" title="<{$key}>" name="UOM">1</td>
				</tr>
				<tr class="<{if $key%2 != 0}>bwhite<{/if}>"> 
					<th class="row-title">产品图片地址</td>
					<td colspan="6" title="<{$key}>" name="">1</td>
				</tr>
				<tr id="product<{$key}>" class="error" style="display:none"></tr>
			<{/foreach}>
			<tr><td align="center" colspan="8"><input type="button" value="检查数据" name="checkData"/></td></tr>
			</table>
			
		</form>		
	</div>
</div>
</div>
<div class="main-bottom"></div>
</div>
<div id="checkResultDialog" style="display:none;text-align:center" title="数据检查结果">
</div>
<div id="tipDialog" style="display:none" title="Tip">
	提交时有错误的产品将会被忽略,是否继续？
</div>
</body>
</html>
